//
//  MsgViewModel.m
//  Jyxt
//
//  Created by tianyun密码123456 on 2017/6/14.
//  Copyright © 2017年 DaLian Rental Housing Management. All rights reserved.
//

#import "MsgViewModel.h"
#import "NetTool.h"
#import "UserCenterViewModel.h"

@implementation MsgViewModel

+ (void)getUnreadMsgInfoWhenSuccess: (void (^__strong)(NSInteger count ,NSString * info))success
                             failed: (void (^)(NSString *reason))failed{
    [NetTool postWithUrl: APIURL(API_MSG_NOT_READ_COUNT) data: @{@"utoken" : [UserCenterViewModel getLocalUToken]} onSuccess:^(NSDictionary *response) {
        if (![response[@"success"] boolValue]){
            failed(response[@"errmsg"]);
            return;
        }
        if ([response[@"count"] integerValue] > 0)
            success([response[@"count"] integerValue], response[@"lastSysMessage"][@"content"]);
        else
            success(0,@"暂无消息");
    } onError:^(NSError *error) {
        failed(@"无法连接到服务器");
    }];
}

@end
